package collection.list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListLoopSample {
    public static void main(String[] args) {
        List<String> bookList = new ArrayList<>();
        bookList.add("鸡你太美");
        bookList.add("你没只因只因");
        bookList.add("只因你太美");
        bookList.add("你妹根了");

        // ------ 1 ------
        for (String book:bookList)
            System.out.println(book);

        // ------ 2 ------
        bookList.forEach(book->{
            System.out.println(book);
        });

        // ------ 3 ------
        Iterator<String> itr = bookList.iterator();
        while (itr.hasNext()) {
            String book = itr.next(); // 提取出下一个元素，同时将指针向后移动
            System.out.println(book);
        }

    }
}
